Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(internal/jujuclient/applicationoffers.go): set user when getting offer consume details #1509

Merged

Conversation

alesstimec
Copy link
Collaborator

When getting consume details for an application offer the juju controller will, among other things,
also return a macaroon that is passed to the consuming side. That macaroon contains a
third party caveat addressed to JIMM in which it instructs JIMM to verify that the user
is consumer of the application offer. Previously we were passing in an empty user tag
which meant that Juju added that 3rd party caveat for the authenticated user and since
JIMM always dials the juju controller as user admin that caveat was instructing JIMM
to check that the admin user has consume access to the application offer.

This PR proposes one way to fix is, which is to specify the user when getting consume
details from the controller. The other way would be to dial the controller as the
logged-in user.

Description

Engineering checklist

  • Documentation updated
  • Covered by unit tests
  • Covered by integration tests

Test instructions

@alesstimec alesstimec requested a review from a team as a code owner January 7, 2025 09:39
Copy link
Contributor

@kian99 kian99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this line in #1329, mentioning "Fix a bug in GetApplicationOfferConsumeDetails to exclude the user field which currently causes an unknown error.". I wish I'd been more descriptive, but it was causing an error in the Terraform Provider's integration tests. It would be good to run the providers tests against JIMM with this change and see what test fails (if any).

internal/jujuclient/applicationoffers.go Show resolved Hide resolved
…offer consume details

When getting consume details for an application offer the juju controller will, among other things,
also return a macaroon  that is passed to the consuming side. That macaroon contains a
third party caveat addressed to JIMM in which it instructs JIMM to verify that the user
is consumer of the application offer. Previously we were passing in an empty user tag
which meant that Juju added that 3rd party caveat for the authenticated user and since
JIMM always dials the juju controller as user `admin` that caveat was instructing JIMM
to check that the `admin` user has `consume` access to the application offer.

This PR proposes one way to fix is, which is to specify the user when getting consume
details from the controller. The other way would be to dial the controller as the
logged-in user.
@alesstimec alesstimec force-pushed the fix-get-application-offer-consume-details branch from 0420fb8 to c82306c Compare January 7, 2025 11:02
Copy link
Contributor

@SimoneDutto SimoneDutto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@alesstimec alesstimec merged commit af73643 into canonical:v3 Jan 8, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants